/**
 * Created by Emily on 16/1/27.
 */
var scrypt = require('scrypt');
var params = scrypt.paramsSync(0.0001);

/**
 * https://github.com/barrysteyn/node-scrypt
 * 用来计算密码是个不错的加密算法
 * toString('base64')
 * toString('hex')
 * @type {string}
 */
var password = "123456";
scrypt.kdf(password, params, function(err, result){
    if (!err) {
        console.log(result.toString('base64'));
        console.log(result.toString());
    } else {
       throw err;
    }
});

//这里的hash就是上面加密得到的结果
var hash = "c2NyeXB0AAoAAAAIAAAAAZLCSlKfCv4OhYZq7QP+37t1fyl9pCMji8cyzmiPdCVANCcfAGVZrbydHqhmIUzNqTKStSkV3o/ukwU9QV19oetb0y4qGu+HqVdrKo5NZykV";
scrypt.verifyKdf(new Buffer(hash, 'base64'), password, function(err, result){
    if (!err) {
      console.log(result);
    } else {
        throw err;
    }
});
